﻿@namespace BlazorComponent
@typeparam TItem
@typeparam TItemValue
@typeparam TValue
@typeparam TInput
@inherits ComponentPartBase<TInput>

<div class="@CssProvider.GetClass("selections")"
     style="@CssProvider.GetStyle("selections")">
    @{
        Type selection;
        if (SelectionContent != null)
        {
            selection = typeof(BSelectSlotSelection<,,,>);
        }
        else if (HasChips)
        {
            selection = typeof(BSelectChipSelection<,,,>);
        }
        else
        {
            selection = typeof(BSelectCommaSelection<,,,>);
        }
    }
    @for (var index = 0; index < SelectedItems.Count; index++)
    {
        var item = SelectedItems[index];
        var selected = index == SelectedIndex;
        var last = index == SelectedItems.Count - 1;
        @RenderPart(selection, item, index, selected ,last)
    }
    @*When SelectedItems changed,blazor will create a new input element*@
    @*This will trigger blur event,so we and a wrapper div and key to avoid it*@
    <div class="@CssProvider.GetClass("input-wrapper")" @key="true">
        @RenderPart(typeof(BTextFieldInput<,>))
    </div>
</div>
